package com.mkait.thief.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.io.Serializable;
import org.springframework.http.HttpStatus;
import org.springframework.lang.Nullable;

@JsonInclude(Include.NON_NULL)
public class ResponseWrapper<T> implements Serializable {
    private static final long serialVersionUID = 4893280118017319089L;
    public static final String SUCCESS_CODE = "200";
    public static final String SUCCESS_MESSAGE = "操作成功";
    public static final String ERROR_CODE = "500";
    public static final String ERROR_MESSAGE = "内部异常";
    public static final String ILLEGAL_ARGUMENT_CODE = "403";
    public static final String ILLEGAL_ARGUMENT_MESSAGE = "参数非法";
    public static final String UNAUTHORIZED_CODE = "401";
    public static final String UNAUTHORIZED_MESSAGE;
    private String code;
    private String message;
    private String subCode;
    private String subMsg;
    private T data;

    ResponseWrapper() {
        this("200", "操作成功");
    }

    ResponseWrapper(String code, String message) {
        this(code, message, (T) null);
    }

    ResponseWrapper(String code, String message, String subCode, String subMsg) {
        this(code, message, subCode, subMsg, (T) null);
    }

    ResponseWrapper(String code, String message, @Nullable T data) {
        this.code(code).message(message).data(data);
    }

    ResponseWrapper(String code, String message, String subCode, String subMsg, @Nullable T data) {
        this.code(code).subCode(subCode).message(message).subMsg(subMsg).data(data);
    }

    private ResponseWrapper<T> code(String code) {
        this.setCode(code);
        return this;
    }

    private ResponseWrapper<T> message(String message) {
        this.setMessage(message);
        return this;
    }

    private ResponseWrapper subCode(String subCode) {
        this.setSubCode(subCode);
        return this;
    }

    private ResponseWrapper<T> subMsg(String subMsg) {
        this.setSubMsg(subMsg);
        return this;
    }

    public ResponseWrapper<T> data(T data) {
        this.setData(data);
        return this;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public String getSubCode() {
        return this.subCode;
    }

    public String getSubMsg() {
        return this.subMsg;
    }

    public T getData() {
        return this.data;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setSubCode(String subCode) {
        this.subCode = subCode;
    }

    public void setSubMsg(String subMsg) {
        this.subMsg = subMsg;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ResponseWrapper)) {
            return false;
        } else {
            ResponseWrapper<?> other = (ResponseWrapper)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label71: {
                    Object this$code = this.getCode();
                    Object other$code = other.getCode();
                    if (this$code == null) {
                        if (other$code == null) {
                            break label71;
                        }
                    } else if (this$code.equals(other$code)) {
                        break label71;
                    }

                    return false;
                }

                Object this$message = this.getMessage();
                Object other$message = other.getMessage();
                if (this$message == null) {
                    if (other$message != null) {
                        return false;
                    }
                } else if (!this$message.equals(other$message)) {
                    return false;
                }

                label57: {
                    Object this$subCode = this.getSubCode();
                    Object other$subCode = other.getSubCode();
                    if (this$subCode == null) {
                        if (other$subCode == null) {
                            break label57;
                        }
                    } else if (this$subCode.equals(other$subCode)) {
                        break label57;
                    }

                    return false;
                }

                Object this$subMsg = this.getSubMsg();
                Object other$subMsg = other.getSubMsg();
                if (this$subMsg == null) {
                    if (other$subMsg != null) {
                        return false;
                    }
                } else if (!this$subMsg.equals(other$subMsg)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data == null) {
                        return true;
                    }
                } else if (this$data.equals(other$data)) {
                    return true;
                }

                return false;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ResponseWrapper;
    }

    public String toString() {
        return "ResponseWrapper(code=" + this.getCode() + ", message=" + this.getMessage() + ", subCode=" + this.getSubCode() + ", subMsg=" + this.getSubMsg() + ", data=" + this.getData() + ")";
    }

    static {
        UNAUTHORIZED_MESSAGE = HttpStatus.UNAUTHORIZED.getReasonPhrase();
    }
}
